package elderberryni2.data.container;

import elderberryni2.abstracts.BaseTimestampable;
import elderberryni2.interfaces.IDumpable;

/**
 * Container for Radial Data on a Globe as Altitude, Longitude and Latitude
 * implements BaseTimestampable to enable use in TimeableLinkedList
 * 
 * @author warringer
 * @version 1.0
 */
public class LocationContainer extends BaseTimestampable<Float>
    implements Comparable<LocationContainer>, IDumpable {
    
    private double altitude;
    private float longitude;
    private float latitude;
    private double alg;

    /**
     * @param altitude
     * @param longitude
     * @param latitude
     * @param alg 
     * @param timeStamp 
     */
    public LocationContainer(double altitude, float longitude, float latitude,
            double alg, float timeStamp) {
        this.altitude = altitude;
        this.longitude = longitude;
        this.latitude = latitude;
        if (alg < 0) {
            this.alg = altitude;
        } else {
            this.alg = alg;
        }
        this.setTimestamp(timeStamp);
    }

    /**
     * @return Altitude 
     */
    public double getAltitude() {
        return altitude;
    }

    /**
     * @return Latitude 
     */
    public float getLatitude() {
        return latitude;
    }

    /**
     * @return Longitude
     */
    public float getLongitude() {
        return longitude;
    }

    /**
     * 
     * @return
     */
    public double getAlg() {
        return alg;
    }

    @Override
    public Float getTimestampDifference(Float timestamp) {
        return Math.abs(this.getTimestamp() - timestamp);
    }

    /**
     * 
     * @param t
     * @return
     */
    @Override
    public int compareTo(LocationContainer t) {
        if (this.altitude == t.getAltitude() &&
                this.alg == t.getAlg() &&
                this.latitude == t.getLatitude() &&
                this.longitude == t.getLongitude()) {
            return 0;
        } else {
            return 1;
        }
    }

    @Override
    public String toCSV() {
        return new Float(altitude).toString() 
                + ";" + new Float(alg).toString() 
                + ";" + new Float(latitude).toString() 
                + ";" + new Float(longitude).toString();
    }

    @Override
    public String getHeader() {
        return "Altitude;Altitude above ground;Latitude;Longitude";
    }
}
